#include "stackplatecheckdig.h"
#include <QMessageBox>
#include "ui_stackplatecheckdig.h"
#include "stackplateinfowid.h"


StackPlateCheckDIg::StackPlateCheckDIg(QWidget* parent)
	: QDialog(parent)
	, ui(new Ui::StackPlateCheckDIg())
{
	ui->setupUi(this);
}

StackPlateCheckDIg::~StackPlateCheckDIg()
{
	delete ui;
}


bool StackPlateCheckDIg::Init(QList<StackPlate*>& plates)
{
	m_wid.clear();
	for (auto iter : plates) {
		auto id = iter->GetPlateId();
		auto temp = new StackPlateInfoWid(this);
		if (!temp->Init(iter)) {
			return false;
		}
		m_wid.append(temp);
		ui->tabWidget->addTab(temp, id);
	}

	return true;
}


bool StackPlateCheckDIg::StartReset()
{
	m_checkFinish = false;
	for (auto& iter : m_wid) {
		iter->ShowInfo();
	}

	exec();

	return m_checkFinish;
}


void StackPlateCheckDIg::on_pushButton_clicked()
{
	auto ret = QMessageBox::question(this, "问题", "请确认是否将所有托盘数据校验完成");
	if (ret == QMessageBox::StandardButton::Yes) {
		m_checkFinish = true;
		this->done(0);
	}
}
